define([
	appBasePath + '/scripts/module.js',
	// appBasePath + '/resources/js/select2.js',
	// appBasePath + '/resources/js/common.js',
	// appBasePath + '/resources/js/special.js',
	// appBasePath + '/resources/js/model1.js',
    ],
    function(substanceModule) {
	substanceModule.directive('page', function(){
		return {
		  restrict: 'E', 
	      transclude: true, 
	      scope: false,
	      controller:['$scope', function($scope){
	    	  $scope.goPage = function(i) {
	    		  $scope.page = {
	    				  currentPage: i
	    		  };
	    		  $scope.loadData();
	    	  }
	      }],
	      template: '<nav style="float:right;">' +
	      			'	<ul class="pagination">' +
	      			'		<li>' +
	      			'			<a ng-click="1 == page.currentPage ? 0 : goPage(1)" aria-label="首页" class="{{1 == page.currentPage ? \'disabled\' : \'\'}}">' +
	      			'			<span aria-hidden="true">&laquo;</span>' +
	      			'			</a>' +
	      			'		</li>' +
	      			'' +
	      			'		<li ng-repeat="p in page.showPages">' +
	      			'			<a ng-click="p == page.currentPage ? 0 : goPage(p)" class="{{p == page.currentPage ? \'li-green\' : \'\'}}">{{p}}</a>' +
	      			'		</li>' +
	      			'' +
	      			'' +
	      			'		<li>' +
	      			'			<a ng-click="page.lastPage == page.currentPage ? 0 : goPage(page.lastPage)" aria-label="尾页" class="{{page.lastPage == page.currentPage ? \'disabled\' : \'\'}}">' +
	      			'			<span aria-hidden="true">&raquo;</span>' +
	      			'			</a>' +
	      			'		</li>' +
	      			'	</ul>' +
	      			'</nav>' +
	      			''
	      			,
	      replace: true
		};
	});
	substanceModule.directive('page2', function(){
		return {
		  restrict: 'E', 
	      transclude: true, 
	      scope: false,
	      controller:['$scope', function($scope){
	    	  $scope.goPage = function(i) {
	    		  $scope.page = {
	    				  currentPage: i
	    		  };
	    		  $scope.loadData();
	    	  }
	      }],
	      template: '<div style="text-align: center;" class="page">' +
	      			'	<span class="pageinfo">当前{{page.currentPage}}/{{page.lastPage}}页&nbsp;每页显示 {{page.pageSize}}条</span>' +
	      			'		<nav>' +
	      			'			<ul class="pagination">' +
	      			'				<li>' +
	      			'					<a ng-click="1 == page.currentPage ? 0 : goPage(1)" aria-label="首页" class="{{1 == page.currentPage ? \'disabled\' : \'\'}}">' +
	      			'						<span aria-hidden="true">&laquo;</span>' +
	      			' 					</a>' +
	      			'				</li>' +
	      			'				<li>' +
	      			'					<a ng-click="page.currentPage == page.prePage ? 0 : goPage(page.prePage)"  aria-label="上一页" class="{{1 == page.prePage ? \'disabled\' : \'\'}}">' +
	      			'						<span aria-hidden="true">&lt;</span>' +
	      			'					</a>' +
	      			'				</li>' +
	      			'				<li ng-repeat="p in page.showPages">' +
	      			'					<a ng-click="p == page.currentPage ? 0 : goPage(p)" class="{{p == page.currentPage ? \'active\' : \'\'}}">{{p}}</a>' +
	      			'				</li>' +
	      			'				<li>' +
	      			'					<a ng-click="page.nextPage == page.currentPage ? 0 : goPage(page.nextPage)" aria-label="下一页" class="{{page.nextPage == page.currentPage ? \'disabled\' : \'\'}}">' +
	      			'						<span aria-hidden="true">&gt;</span>' +
	      			'					</a>' +
	      			'				</li>' +
	      			'				<li>' +
	      			'					<a ng-click="page.lastPage == page.currentPage ? 0 : goPage(page.lastPage)" aria-label="尾页" class="{{page.lastPage == page.currentPage ? \'disabled\' : \'\'}}">' +
	      			'						<span aria-hidden="true">&raquo;</span>' +
	      			'					</a>' +
	      			'				</li>' +
	      			'			</ul>' +
	      			'		</nav>	' +
	      			'</div>' +
	      			'' +
	      			'' +
	      			'' +
	      			'' +
	      			'' +
	      			'' +
	      			'' +
	      			'' +
	      			''
	      			,
	      replace: true
		};
	});
	substanceModule.config([
		    '$stateProvider', 
		    'gbits.websns.substance.config',
		    function($stateProvider, substanceConfig) {
		    	var basePath = substanceConfig.basePath;
		    	
		    	// 以下为应用demo的路由配置
		    	$stateProvider
		        .state(appStatePrefix+'substance', {
		        	url: '/substance',
		        	templateUrl: basePath + '/view/index.html',
		        	controller:'Demo.MainController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
		            				       
	            				       	basePath + '/controller/MainController.js',
	            				       	basePath + '/common/http.js',
	            				       	basePath + '/service/todo.js',
	            				       	
	            				       	basePath + '/service/SubjectService.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.create', {
		        	url: '/create',
		        	templateUrl: basePath + '/view/create.html',
		        	controller:'Demo.CreateController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/CreateController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.list', {
		        	url: '/list',
		        	templateUrl: basePath + '/view/list.html',
		        	controller:'Demo.ListController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/ListController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.edit', {
		        	url: '/edit/{id}',
		        	templateUrl: basePath + '/view/edit.html',
		        	controller:'Demo.EditController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/EditController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        // 物资管理
		        .state(appStatePrefix+'substance.goodslist', {
		        	url: '/goodslist/{currentPage}',
		        	templateUrl: basePath + '/view/goods_list.html',
		        	controller:'Substance.GoodsListController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/GoodsListController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.goodscreate', {
		        	url: '/goodscreate',
		        	templateUrl: basePath + '/view/goods_create.html',
		        	controller:'Substance.GoodsCreateController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/GoodsCreateController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.goodsedit', {
		        	url: '/goodsedit/{id}',
		        	templateUrl: basePath + '/view/goods_edit.html',
		        	controller:'Substance.GoodsEditController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/GoodsEditController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        .state(appStatePrefix+'substance.goodsshow', {
		        	url: '/goodsshow',
		        	templateUrl: basePath + '/view/goods_show.html',
		        	controller:'Substance.GoodsShowController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/GoodsShowController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        .state(appStatePrefix+'substance.goodsapproval', {
		        	url: '/goodsapproval',
		        	templateUrl: basePath + '/view/goods_approval.html',
		        	controller:'Substance.ApprovalController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/ApprovalController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        .state(appStatePrefix+'substance.goodsstoreout', {
		        	url: '/goodsstoreout',
		        	templateUrl: basePath + '/view/goods_storeout.html',
		        	controller:'Substance.StoreOutController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/StoreOutController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        .state(appStatePrefix+'substance.goodsapplylist', {
		        	url: '/goodsapplylist',
		        	templateUrl: basePath + '/view/apply_list.html',
		        	controller:'Substance.GetRecordsController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/GetRecordsController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        .state(appStatePrefix+'substance.userMgrSetting', {
		        	url: '/userMgrSetting',
		        	templateUrl: basePath + '/view/usermgr_setting.html',
		        	controller:'Substance.UserMgrSettingController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/UserMgrSettingController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.approvalSetting', {
		        	url: '/approvalSetting',
		        	templateUrl: basePath + '/view/userapproval_setting.html',
		        	controller:'Substance.UserApprovalSettingController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/UserApprovalSettingController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        .state(appStatePrefix+'substance.storeinrecords', {
		        	url: '/storeinrecords',
		        	templateUrl: basePath + '/view/goods_storein_records.html',
		        	controller:'Substance.StoreRecordController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/StoreRecordController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        // 实时库存
		        .state(appStatePrefix+'substance.storedetail', {
		        	url: '/storedetail',
		        	templateUrl: basePath + '/view/goods_store_detail.html',
		        	controller:'Substance.StoreDetailController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/StoreDetailController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        // 已申请列表
		        .state(appStatePrefix+'substance.userApplyList', {
		        	url: '/userApplyList',
		        	templateUrl: basePath + '/view/user_applylist.html',
		        	controller:'Substance.UserApplyController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/UserApplyController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        // 已申请列表
		        .state(appStatePrefix+'substance.userApplyingList', {
		        	url: '/userApplyingList',
		        	templateUrl: basePath + '/view/user_applyinglist.html',
		        	controller:'Substance.UserApplyingController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/UserApplyingController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        // 已审批记录
		        .state(appStatePrefix+'substance.userApprovedList', {
		        	url: '/userApprovedList',
		        	templateUrl: basePath + '/view/user_approvedlist.html',
		        	controller:'Substance.UserApprovedController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/UserApprovedController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        
		        
		        .state(appStatePrefix+'substance.subjecttest', {
		        	url: '/subjecttest',
		        	templateUrl: basePath + '/view/subject_test.html',
		        	controller:'Substance.SubjectTestController',
		        	resolve: {
		                load: ['$ocLazyLoad', 
		                    function($ocLazyLoad) {
		                		return $ocLazyLoad.load({
		                			name:'gbits.websns.substance',
		            				files:[
	            				       	basePath + '/controller/SubjectTestController.js',
		    					 	]}
		        				);
		                	}
		                ]
		            }
		        })
		        ;		    	
			}
	    ])	
	}
);
